<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search" inline>
      <el-form-item label="所属公司">
        <TenantChoose @loaded="search" v-model="form.tenant_id" />
      </el-form-item>
      <br />
      <el-form-item label="所属站点">
        <SiteRadioAll v-model="form.site_id" @change="search" />
      </el-form-item>

      <br />

      <el-form-item label="状态">
        <el-radio-group v-model="form.status" @change="search">
          <el-radio-button :label="99">全部</el-radio-button>
          <el-radio-button :label="0">待审核</el-radio-button>
          <el-radio-button :label="1">已审核</el-radio-button>
          <el-radio-button :label="2">已拒绝</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-form-item label="类型">
        <el-radio-group v-model="form.cate" @change="search">
          <el-radio-button label="">全部</el-radio-button>
          <el-radio-button label="推荐注册">推荐注册</el-radio-button>
          <el-radio-button label="分享工作">分享工作</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-form-item label="产生时间">
        <el-date-picker
          v-model="form.create_time_s"
          class="filter-item"
          type="date"
          placeholder="开始"
          value-format="YYYY-MM-DD"
          style="width: 150px"
        />
        <el-date-picker
          v-model="form.create_time_e"
          class="filter-item"
          type="date"
          placeholder="结束"
          value-format="YYYY-MM-DD"
          style="width: 150px; margin-left: 8px"
        />
      </el-form-item>
      <br />

      <el-form-item label="推荐人">
        <el-input clearable v-model.trim="form.parent_realname" />
      </el-form-item>
      <el-form-item label="工作人">
        <el-input clearable v-model.trim="form.member_realname" />
      </el-form-item>

      <el-form-item label-width="16px">
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { EleMessage } from 'ele-admin-plus/es';
  import { getCityList } from '@/api/system/region';
  import { getTenantList } from '@/api/tenant';
  import { useFormData } from '@/utils/use-form-data';
  import { ref } from 'vue';
  const emit = defineEmits(['search']);
  const props = defineProps({
    where: Object
  });
  /** 表单数据 */
  const [form] = useFormData({
    status: 0,
    pay_type: '',
    cate: '',
    site_id: 0,
    create_time_s: '',
    create_time_e: '',
    realname: '',
    tel: '',
    tenant_id: 0
  });
  if (props.where) {
    form.status = props.where.status ?? 0;
    form.create_time_s = props.where.create_time_s ?? '';
    form.create_time_e = props.where.create_time_e ?? '';
  }
  /** 站点数据 */
  const cityList = ref([]);

  /** 获取站点数据 */
  getCityList({})
    .then((res) => {
      cityList.value = res.list;
      console.log(form);
    })
    .catch((e) => {
      EleMessage.error(e.message);
    });

  /** 租户数据 */
  const tenantList = ref([]);

  /** 获取租户数据 */
  getTenantList({})
    .then((res) => {
      tenantList.value = res.list;
    })
    .catch((e) => {
      EleMessage.error(e.message);
    });

  /** 搜索 */
  const search = () => {
    console.log(form);
    emit('search', { ...form });
  };
</script>
